<template>
  <div class="icons" >
    <ul >
       <swiper  :options="swiperOption">
            <swiper-slide v-for="page of pages"  >
              <router-link
                :to="'/iconinfo/'+iconImg.id"
                tag="li"
                class="icon-info"
                v-for="iconImg of page"
                :key="iconImg.id">
                    <img :src="iconImg.imgUrl">
                    <p>{{iconImg.title}}</p>
              </router-link>
            </swiper-slide>
         <div slot="pagination" class="swiper-pagination"></div>
       </swiper>

    </ul>
  </div>
</template>
<script>
export default {
  name: 'Homeicons',
  props: {
    list: Array
  },
  data(){
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
      },
    }
  },
  computed: {
    pages () {
      const pages = [];
      this.list.forEach( (list,index) =>{
        const page = Math.floor(index/8);
        if(!pages[page]){
           pages[page] = []
        }
        pages[page].push(list)
      });
      return  pages
    }
  }
}
</script>
<style scpoed>
  .icons {
    width: 100%;
    height: 0;
    padding-bottom: 53%;
    overflow: hidden;
    margin-top:-3px;
  }
  .icon-info {
    width:25%;
    height: 50%;
    float: left;
  }
  .icon-info img{
    padding-left: 10%;
    width:80%;
  }
  .icon-info>p {
    line-height: 24px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .swiper-pagination {
    color:white;
  }
</style>
